package day11.KeJian;

import java.util.*;
import java.util.stream.Stream;

public class StreamDemo1 {
    public static void main(String[] args) {
        //Collection体系的集合可以使用默认方法stream()生成流
        ArrayList<String> list = new ArrayList<>();
        Stream<String> liststream = list.stream();
        HashSet<String> set = new HashSet<>();
        Stream<String> setstream = set.stream();
        //Map体系的集合间接的生成流
        Map<String, Integer> map = new HashMap<>();
        Stream<String> keystream = map.keySet().stream();
        Stream<Integer> valuesstream = map.values().stream();
        Stream<Map.Entry<String, Integer>> entrystream = map.entrySet().stream();
        //数组可以通过Arrays中的静态方法stream生成流
        String[] strArray = {"hello","world","java"};
        Stream<String> stream = Arrays.stream(strArray);
        //同种数据类型的多个数据可以通过Stream接口的静态方法of(T... values)生成流
        Stream<String> strArrayStream2 = Stream.of("hello", "world", "java");
        Stream.of(10, 20, 30);
    }
}
